"""
File:views_base_serializer.py
Author:Tcyw
Date:2020-03-25
Connect:741047561@qq.com
Description:

"""
from django.core import serializers
from django.http import JsonResponse
from django.views import View

from app.goods.models import Goods


class GoodsListSerializerView(View):
    def get(self,request):
        #获取所有商品
        goods = Goods.objects.all()[:5]
        json_data = serializers.serialize('json',goods)

        #In order to allow non-dict objects to be serialized set the safe parameter to False.
        return JsonResponse(json_data,safe=False)
